<!-- 个人认证 -->
<template>
  <div class="page-box h100 display-flex czbj" v-if="xcxzsdfrrt">
    <p class="title-label mb10">个人认证</p>
    <!-- sonRouter="yybureauFormationBJ" 为跳转新的页面编辑 -->
    <dxtable
      :dataJson="dataJson"
      :portUrl="portUrl"
      :formJson="formJson"
      :qx="qx"
      ref="databale"
    ></dxtable>
  </div>
</template>
<script lang="ts" setup>
import { Options } from "@vicons/ionicons5";
import dxtable from "../../../components/util/dxtable.vue";
import sort from "../../../components/util/sort.vue";
import { dxget, dxpost, hf } from "../../../util/index";
import { NButton, NImage, NTag } from "naive-ui";
import { h, ref, reactive, render } from "vue";
const databale = ref();
const xcxzsdfrrt = ref(false);
const jiaose = ref([]);
const initeer = () => {
  databale.value.initDataExpose();
};

const kkmxdopt = [
  {
    label: "审核中",
    value: "1",
  },
  {
    label: "审核通过",
    value: "2",
  },
  {
    label: "审核不通过",
    value: "3",
  },
];
let dataJson = [
  {
    title: "头像",
    type: "img",
    val: "",
    icon: "dx-img",
    span: 12,
    key: "headPortrait",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "手机号码",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 12,
    key: "phone",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "角色",
    type: "select",
    options: [],
    val: "",
    icon: "dx-shurukuang",
    span: 12,
    key: "jiaoseId",
    width: "",
    search: true,
    istable: true,
    required: false,
    render(row) {
      try {
        return jiaose.value.filter((a) => a.value == row.jiaoseId)[0].label;
      } catch (e) {}
    },
  },
  {
    title: "证明",
    type: "img",
    val: "",
    icon: "dx-img",
    span: 12,
    key: "zhengming",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "审核",
    type: "select",
    icon: "dx-radiobox",
    val: "",
    key: "shenhe",
    options: kkmxdopt,
    search: true,
    render(row) {
      if (row.shenhe == 1) {
        return h("span", { class: "z9" }, kkmxdopt[0].label);
      }
      if (row.shenhe == 2) {
        return h("span", { class: "ls" }, kkmxdopt[1].label);
      }
      if (row.shenhe == 3) {
        return h("span", { class: "red" }, kkmxdopt[2].label);
      }
    },
  },
  {
    title: "添加时间",
    key: "addTime",
    width: 150,
  },
];

const qx = {
  DeletePermissionID: "jchusergrxxrzdel", //删除
  EditPermissionIdentifier: "jchusergrxxrzbj", // 编辑
  NewPermissionIdentifier: "jchusergrxxrzxz", // 新建
  ViewPermissionID: "jchusergrxxrzck", // 查看
};
const portUrl = "jiacaihui/grxxrz";

let formJson = reactive([
  // {
  //   title: "头像",
  //   type: "img",
  //   val: "",
  //   icon: "dx-img",
  //   span: 12,
  //   key: "headPortrait",
  //   width: "",
  //   search: false,
  //   istable: true,
  //   required: false,
  // },
  // {
  //   title: "真实姓名",
  //   type: "input",
  //   val: "",
  //   icon: "dx-shurukuang",
  //   span: 12,
  //   key: "name",
  //   width: "",
  //   search: false,
  //   istable: true,
  //   required: false,
  // },
  // {
  //   title: "手机号码",
  //   type: "input",
  //   val: "",
  //   icon: "dx-shurukuang",
  //   span: 12,
  //   key: "phone",
  //   width: "",
  //   search: false,
  //   istable: true,
  //   required: false,
  // },
  {
    title: "角色",
    type: "select",
    options: [],
    val: "",
    icon: "dx-shurukuang",
    span: 12,
    key: "jiaoseId",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "证明",
    type: "img",
    val: "",
    icon: "dx-img",
    span: 12,
    key: "zhengming",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "审核",
    type: "radio",
    icon: "dx-radiobox",
    val: "2",
    opt: [
      {
        label: "审核通过",
        value: "2",
      },
      {
        label: "审核不通过",
        value: "3",
      },
    ],
    span: 12,
    key: "shenhe",
    width: "",
    search: false,
    istable: true,
    required: false,
    callBack: (data) => {
      if (data == 3) {
        formJson[3].hide = false;
      } else {
        formJson[3].val = "";
        formJson[3].hide = true;
      }
    },
  },
  {
    title: "不通过原因",
    type: "textarea",
    val: "",
    icon: "dx-duohangwenben",
    span: 24,
    key: "yuanying",
    width: "",
    search: false,
    istable: true,
    required: false,
    hide: true,
  },
]);
const czFun = {
  fun: (row) => {
    return [
      h(
        NButton,
        {
          type: "info",
          quaternary: true,
          onClick: async (e) => {
            hf("jchcompany");
          },
        },
        "添加公司"
      ),
    ];
  },
};

// 获取字典内容
const xtgxxmfl = async () => {
  const { data }: any = await dxget("dxgjAdmin/getzd", { name: "jchjs" });
  jiaose.value = data;
  dataJson[2].options = [
    {
      label: "全部",
      value: "",
    },
    ...data,
  ];
  formJson[0].options = data;

  xcxzsdfrrt.value = true;
};
xtgxxmfl();
</script>
<style scoped></style>
